import { Component } from "react";
import { View, Text } from "@tarojs/components";
import { getCurrentInstance, setNavigationBarTitle } from "@tarojs/taro";
import { getArticleDetail } from "@/api/article";
import "./index.less";

export default class Index extends Component {
  state = {
    articleData: {},
  };

  $instance = getCurrentInstance();

  async componentDidMount() {
    const res = await getArticleDetail({
      id: this.$instance.router?.params.id,
    });

    this.setState({ articleData: res.data[0] });
    setNavigationBarTitle({
      title: res.data[0].title,
    });
  }

  render() {
    const { articleData } = this.state;
    const { content } = articleData;

    return (
      <View className="index">
        <wemark md={content} link highlight type="wemark" />
      </View>
    );
  }
}
